<?php
use yii\helpers\Url;
use app\data\StaffData;
use yii\bootstrap\ActiveForm;
$this->context->layout=false;

?>
<?php
//使用率
echo $this->render("@app/views/public/useRate.php")
?>
<?php 
	$form = ActiveForm::begin([
		'id' => 'm-form',
        'options' => [
        	'class' => 'form-horizontal'
        ]
    ]);
?>
	<div style="margin:15px;">
		
		<div class="panel panel-default">
			<div class="panel-heading">基本资料</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
					<table class="table">
						<tr>
							<th width="20%">
								中文名：
							</th>
							<td width="30%">
								<input type="text" class="k-input k-textbox" name="name_cn_long" value="<?=$oData['name_cn_long']; ?>">
							</td>
							<th width="20%">
								英文名：
							</th>
							<td width="30%">
								<input type="text" class="k-input k-textbox" name="name_en_long" value="<?=$oData['name_en_long']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								性别：
							</th>
							<td>
								<input type="text" id="gender" name="gender">
							</td>
							<th>
								婚姻状态：
							</th>
							<td>
								<input type="text" id="marital_status"  name="marital_status">
							</td>
						</tr>

						<tr>
							<th>
								出生日期：
							</th>
							<td>
								
								<input type="text" id="dob" name="dob">
							</td>
							<th>
								民族：
							</th>
							<td>
								<input type="text" class="k-input k-textbox" name="nation" value="<?=$oData['nation']; ?>">
							</td>
						</tr>


						<tr>
							<th>
								学历：
							</th>
							<td>
								<input type="text" id="education" name="education">
							</td>
							<th>
								毕业学校：
							</th>
							<td>
								<input type="text" class="k-input k-textbox" name="graduation_school" value="<?=$oData['graduation_school']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								专业：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="major" value="<?=$oData['major']; ?>">
							</td>
							<th>
								身份证号码：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="identity_card_number" value="<?=$oData['identity_card_number']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								联系电话：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="phone_number" value="<?=$oData['phone_number']; ?>">
							</td>
							<th>
								邮件：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="email" value="<?=$oData['email']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								政治地位：
							</th>
							<td>			
								<input type="text" id="political_status" name="political_status">
							</td>
							<th>
								序列号：
							</th>
							<td>
								<input type="text" class="k-input k-textbox" name="serial_number" value="<?=$oData['serial_number']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								家庭类型：
							</th>
							<td>
				
								<input type="text" class="k-input k-textbox" name="household_category" value="<?=$oData['household_category']; ?>">					
							</td>
							<th>
								家庭住址：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="household_location" value="<?=$oData['household_location']; ?>">	
							</td>
						</tr>

						<tr>
							<th>
								银行名称：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="bank_name" value="<?=$oData['bank_name']; ?>">							
							</td>
							<th>
								银行号码：
							</th>
							<td>
								<input type="text" class="k-input k-textbox" name="bank_number" value="<?=$oData['bank_number']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								紧急联系人：
							</th>
							<td>
								<input type="text" class="k-input k-textbox" name="emergency_contact" value="<?=$oData['emergency_contact']; ?>">						
							</td>
							<th>
								紧急联系人号码：
							</th>
							<td>
								<input type="text" class="k-input k-textbox" name="emergency_contact_phone_number" value="<?=$oData['emergency_contact_phone_number']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								地址1：
							</th>
							<td colspan="3">
									
								<input type="text" class="k-input k-textbox" name="address1" value="<?=$oData['address1']; ?>" style="width:100%">						
							</td>
							
						</tr>
						<tr>
							<th>
								地址2：
							</th>
							<td colspan="3">
								
								<input type="text" class="k-input k-textbox" name="address2" value="<?=$oData['address2']; ?>" style="width:100%">
							</td>
						</tr>
						
					</table>
				</div>
			</div>
		</div>
		<Br>

		<div class="panel panel-default">
			<div class="panel-heading">职位资料</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
					<table class="table">
						<tr>
							<th width="20%">
								部门名称：
							</th>
							<td width="30%">
								<input type="text"  id="department_id" name="department_id">

								<input type="hidden"  id="department_name" name="department_name" value="<?=$oData['department_name']; ?>">
							</td>
							<th width="20%">
								职位：
							</th>
							<td width="30%">
								
								<select id="position_id" name="position_id"></select>
								<input type="hidden" id="position_name" name="position_name" value="<?=$oData['position_name']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								组别：
							</th>
							<td>
								<!-- <input type="text" id="group_id" name="group_id"> -->
								<select id="group_id" name="group_id"></select>
								<input type="hidden" id="group_name" name="group_name" value="<?=$oData['group_name']; ?>">
							</td>
							<th>
								在职状态：
							</th>
							<td>

								<input type="text" id="position_status" name="position_status">
							</td>
						</tr>


						<tr>
							<th>
								入职日期：
							</th>
							<td>
								<input type="text" id="hired_date" name="hired_date">
							</td>
							<th>
								指纹号：
							</th>
							<td>
								
								<input type="text" class="k-input k-textbox" name="finger_print_number" value="<?=$oData['finger_print_number']; ?>">
							</td>
						</tr>

						<tr>
							<th>
								合同状态
							</th>
							<td>
								<input type="text" id="contract_status" name="contract_status">
							</td>
							<th>
								工作地点：
							</th>
							<td>
								<input type="text" id="work_place" name="work_place" value="<?=$oData['work_place']; ?>">
							</td>
						</tr>

					</table>
				</div>
			</div>
		</div>
		
		<br>

		<div class="panel panel-default">
			<div class="panel-heading">教育经历</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
			  		<div class="m-box">
			  			<a type="button" id="add-education" class="k-button k-button-icontext" href="javascript:;"><i class="glyphicon glyphicon-plus"></i>添加</a>
						<div id="education-box">
							<?php foreach ($oData['education_ext'] as $key => $value):?>
							<div class="row m-table-row m-tr" style="margin-top:10px;" data-id="<?=$value['id']; ?>">
								&nbsp;&nbsp;
								<input type="hidden" name="education_id[]" value="<?=$value['id']; ?>"/>
								<div class="label">开始时间</div>
								&nbsp;&nbsp;
								<input type="text" id="start_date_<?=$value['id']; ?>" name="education_start_date_arr[]" style="width:121px;float:left;" value="<?=date("m/d/Y",strtotime($value['start_date'])); ?>">
								&nbsp;&nbsp;
								<div class="label">结束时间</div>
								&nbsp;&nbsp;
								<input type="text" id="end_date_<?=$value['id']; ?>" name="education_end_date_arr[]" style="width:121px;float:left;" value="<?=date("m/d/Y",strtotime($value['end_date'])); ?>">
								&nbsp;&nbsp;
								<div class="label">教育机构</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="education_organization_arr[]" style="width:121px;float:left;" value="<?=$value['education_organization']; ?>">
								<br>
								<br>
								&nbsp;&nbsp;
								<div class="label">专业</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="education_major_arr[]" style="width:121px;float:left;" value="<?=$value['major']; ?>">
								&nbsp;&nbsp;
								<div class="label">学历</div>
								&nbsp;&nbsp;
								<input type="text" id="education_<?=$value['id']; ?>" name="educational_arr[]" style="width:121px;float:left;" >
								&nbsp;&nbsp;
								<a href="javascript:;" class="del-education"><i class="glyphicon glyphicon-remove"></i></a>
							</div>
							<?php endforeach; ?>
						</div>
					</div>
			  	</div>
			</div>
		</div>

		<br>
		<div class="panel panel-default">
			<div class="panel-heading">员工证书</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
			  		<div class="m-box">
			  			<a type="button" id="add-certificate" class="k-button k-button-icontext" href="javascript:;"><i class="glyphicon glyphicon-plus"></i>添加</a>

						<table class="table" id="certificate-table" style="margin-top:10px">
							<?php foreach ($oData['certificate_ext'] as $key => $value):?>
							<tr class="m-tr" data-id="<?=$value['id'] ?>">
								<th width="16%">
								<input type="hidden" name="certificate_id[]" value="<?=$value['id'] ?>"/>
									时间：
								</th>
								<td width="16%">
									<input type="text" id="get_date_<?=$value['id'] ?>" name="certificate_get_date_arr[]" style="width:120px;" value="<?=date('m/d/Y',strtotime($value['get_date'])) ?>">
								</td>
								<th width="16%">
									名称：
								</th>
								<td width="16%">
									<input type="text" class="k-input k-textbox" name="certificate_name_arr[]" style="width:120px;" value="<?=$value['certificate_name'] ?>">
								</td>
								<th width="16%">
									成绩：
								</th>
								<td width="16%">
									<input type="text" class="k-input k-textbox" name="certificate_result_arr[]" style="width:120px;" value="<?=$value['result'] ?>">
								</td>
								<td width="1%">
									<a href="javascript:;" class="del-certificate"><i class="glyphicon glyphicon-remove"></i></a>
								</td>
							</tr>
							<?php endforeach; ?>
						</table>
			  	</div>
			</div>
		</div>
		<br>

		<div class="panel panel-default">
			<div class="panel-heading">家庭成员</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
			  		<div class="m-box">
			  			<a type="button" id="add-member" class="k-button k-button-icontext" href="javascript:;"><i class="glyphicon glyphicon-plus"></i>添加</a>
						<div id="member-box">
							<?php foreach ($oData['member_ext'] as $key => $value):?>
							<div class="row m-table-row m-tr" style="margin-top:10px;" data-id="<?=$value['id'] ?>">
								&nbsp;&nbsp;
								<input type="hidden" name="member_id[]" value="<?=$value['id'] ?>"/>
								<div class="label">姓名</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="member_name_arr[]" style="width:121px;float:left;" value="<?=$value['member_name'] ?>">
								&nbsp;&nbsp;
								<div class="label">关系</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="member_relationship_arr[]" style="width:121px;float:left;" value="<?=$value['relationship'] ?>">
								&nbsp;&nbsp;
								<div class="label">工作单位</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="member_work_unit_arr[]" style="width:121px;float:left;" value="<?=$value['work_unit'] ?>">
								<br>
								<br>
								&nbsp;&nbsp;
								<div class="label">职业</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="member_position_name_arr[]" style="width:121px;float:left;" value="<?=$value['member_position_name'] ?>">
								&nbsp;&nbsp;
								<div class="label">电话</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="member_tel_arr[]" style="width:121px;float:left;" value="<?=$value['tel'] ?>">
								&nbsp;&nbsp;
								<a href="javascript:;" class="del-member"><i class="glyphicon glyphicon-remove"></i></a>
							</div>
							<?php endforeach; ?>
						</div>
			  	</div>
			</div>
		</div>
		<br>
		<div class="panel panel-default">
			<div class="panel-heading">工作经验</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
			  		<div class="m-box">
			  			<a type="button" id="add-word" class="k-button k-button-icontext" href="javascript:;"><i class="glyphicon glyphicon-plus"></i>添加</a>
						<div id="word-box">
							<?php foreach ($oData['work_ext'] as $key => $value):?>
							<div class="row m-table-row m-tr" style="margin-top:10px;" data-id="<?=$value['id'] ?>">
								&nbsp;&nbsp;
								<input type="hidden" name="word_id[]" value="<?=$value['id'] ?>"/>
								<div class="label">开始时间</div>
								&nbsp;&nbsp;
								<input type="text" id="start_date_<?=$value['id'] ?>" name="word_start_date_arr[]" style="width:121px;float:left;" value="<?=date('m/d/Y',strtotime($value['start_date'])) ?>">
								&nbsp;&nbsp;
								<div class="label">结束时间</div>
								&nbsp;&nbsp;
								<input type="text" id="end_date_<?=$value['id'] ?>" name="word_end_date_arr[]" style="width:121px;float:left;" value="<?=date('m/d/Y',strtotime($value['end_date'])) ?>">
								&nbsp;&nbsp;
								<div class="label">单位名称</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="word_unit_name_arr[]" style="width:121px;float:left;" value="<?=$value['unit_name'] ?>">
								<br>
								<br>
								&nbsp;&nbsp;
								<div class="label">职位</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="word_position_name_arr[]" style="width:121px;float:left;" value="<?=$value['position_name'] ?>">
								&nbsp;&nbsp;
								<div class="label">离职原因</div>
								&nbsp;&nbsp;
								<input type="text" class="k-input k-textbox" name="word_leave_reason_arr[]" style="width:121px;float:left;" value="<?=$value['leave_reason'] ?>">
								&nbsp;&nbsp;
								<a href="javascript:;" class="del-work"><i class="glyphicon glyphicon-remove"></i></a>
							</div>
							<?php endforeach; ?>
						</div>
			  	</div>
			</div>
		</div>


		<br>
		<div class="panel panel-default">
			<div class="panel-heading">员工福利</div>
			<div class="panel-body m-panel-body">
			  	<div class="m-box">
			  		<div class="m-box">
						<div id="word-box_add">
							<table class="table">
								<tr>
									<th width="30%">
										停车类型：
									</th>
									<td width="70%">
										<input type="text"  id="park_type" name="park_type">
									</td>
								
								</tr>
							</table>
						</div>
			  		</div>
				</div>
			</div>
		</div>


		
	</div>
	<a type="button" class="k-button k-button-icontext" id="m-submit" href="javascript:;" style="margin-top:20px;float:right;"><i class="glyphicon glyphicon-plus"></i>提交</a>

<?php ActiveForm::end(); ?>

<script>

var _contractData = JSON.parse('<?=json_encode(StaffData::getContractStatus()); ?>');
//工作地點
var _workPlaceData = JSON.parse('<?=json_encode(StaffData::getWorkPlace()); ?>');
//在職狀態
var _positionStatusData = JSON.parse('<?=json_encode(StaffData::getPositionStatus()); ?>');
//性別
var _genderData = JSON.parse('<?=json_encode(StaffData::getGender()); ?>');
//婚姻狀態
var _maritalStatusData = JSON.parse('<?=json_encode(StaffData::getMarriage()); ?>');
//學歷
var _educationData = JSON.parse('<?=json_encode(StaffData::getEducation()); ?>');
//政治地位
var _politicalStatusData = JSON.parse('<?=json_encode(StaffData::getPoliticalStatus()); ?>');


$(function(){

	$("#m-submit").click(function(){
		var _this=$(this);
		_this.parents("#m-form").ajaxSubmit({
			url : "<?=Url::to(['update']); ?>",
			data:{id:"<?=$oData['id']; ?>"},
			dataType:"json",
			success:function(redata){
				if(redata.status==1){
					var _editWindow = editWindow.data('kendoWindow');
				    _editWindow.refresh();
				    _grid.data("kendoGrid").dataSource.read();
				    _grid.data("kendoGrid").refresh();
					_editWindow.close();
				}else{
					layer.msg(redata.info, {icon: 5});
				}
			}
		})
	})

	$(".del-certificate").click(function(e){
		var _this = $(this);
		var _id = $(this).parents(".m-tr").data("id")
		$.ajax({
			url :"<?=Url::to(['delcertificate']); ?>",
			data:{certificate_id:_id},
			dataType:"json",
			type:"GET",
			success:function(d){
				if(d.status == 1){
					_this.parents(".m-tr").remove();
				}else{
					layer.msg(d.info, {icon: 5});
				}
			}
		})
	})

	$(".del-education").click(function(e){
		var _this = $(this);
		var _id = $(this).parents(".m-tr").data("id")

		$.ajax({
			url :"<?=Url::to(['deleducation']); ?>",
			data:{education_id:_id},
			dataType:"json",
			type:"GET",
			success:function(d){
				if(d.status == 1){
					_this.parents(".m-tr").remove();
				}else{
					layer.msg(d.info, {icon: 5});
				}
			}
		})
	})

	$(".del-member").click(function(e){
		var _this = $(this);
		var _id = $(this).parents(".m-tr").data("id")
	
		$.ajax({
			url :"<?=Url::to(['delmember']); ?>",
			data:{member_id:_id},
			dataType:"json",
			type:"GET",
			success:function(d){
				if(d.status == 1){
					_this.parents(".m-tr").remove();
				}else{
					layer.msg(d.info, {icon: 5});
				}
			}
		})
	})

	$(".del-work").click(function(e){
		var _this = $(this);
		var _id = $(this).parents(".m-tr").data("id")

		$.ajax({
			url :"<?=Url::to(['delwork']); ?>",
			data:{work_id:_id},
			dataType:"json",
			type:"GET",
			success:function(d){
				if(d.status == 1){
					_this.parents(".m-tr").remove();
				}else{
					layer.msg(d.info, {icon: 5});
				}
			}
		})
	})

    $.ajax({
    	url: "<?=Url::toRoute(['/hr/unit/default/getselectall']); ?>",
        dataType: "json",
        type:"GET",
        success:function(redata){
        	var _departmentDataId= new Array;
        	for (var i = 0; i < redata.length ; i++) {
        		_departmentDataId[i]=redata[i].value;
        	}
        	//单选控件
			$("#department_id").kendoDropDownList({
		        dataTextField: "text",
		        dataValueField: "value",
		        dataSource: redata,
		        index:_departmentDataId.indexOf("<?=$oData['department_id'] ?>"),
		        change:function(e){
		        	var _id = $("#department_id").data("kendoDropDownList").value();
		        	setGroup(_id,false);
		        	setPosition(_id,false);
		        }
		    })
		    //设置组别
		    setGroup('<?=$oData["department_id"]; ?>',true);
		    setPosition('<?=$oData["department_id"]; ?>',true);
        }
    })

     $("#park_type").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource:JSON.parse('<?=json_encode(StaffData::getParkType()) ?>'),
        index:<?=StaffData::getSelectIndex($oData['park_type'],StaffData::getParkType()); ?>
    })

    $("#contract_status").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: _contractData,
        index:<?=StaffData::getSelectIndex($oData['contract_status'],StaffData::getContractStatus()); ?>
    })

    $("#work_place").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource:_workPlaceData,
        index:<?=StaffData::getSelectIndex($oData['work_place'],StaffData::getWorkPlace()); ?>
    })

    $("#position_status").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: _positionStatusData,
        index:<?=StaffData::getSelectIndex($oData['position_status'],StaffData::getPositionStatus()); ?>
    })

    $("#gender").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: _genderData,
        index:<?=StaffData::getSelectIndex($oData['gender'],StaffData::getGender()); ?>
    })

    $("#marital_status").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: _maritalStatusData,
        index:<?=StaffData::getSelectIndex($oData['marital_status'],StaffData::getMarriage()); ?>
    })

    $("#education").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: _educationData,
        index:<?=StaffData::getSelectIndex($oData['education'],StaffData::getEducation()); ?>
    })

    $("#political_status").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: _politicalStatusData,
        index:<?=StaffData::getSelectIndex($oData['political_status'],StaffData::getEducation()); ?>
    })

    $("#hired_date").kendoDatePicker({
    	format:"MM/dd/yyyy",
        value:"<?=date('m/d/Y',strtotime($oData['hired_date'])); ?>"
    });

    $("#dob").kendoDatePicker({
    	format:"MM/dd/yyyy",
        value:"<?=date("m/d/Y",strtotime($oData['dob'])); ?>"
    });

    <?php foreach ($oData['education_ext'] as $key => $value):?>
	    $("#start_date_<?=$value['id'] ?>").kendoDatePicker({format:"MM/dd/yyyy"});
	    $("#end_date_<?=$value['id'] ?>").kendoDatePicker({format:"MM/dd/yyyy"});
	    $("#education_<?=$value['id'] ?>").kendoDropDownList({
	        dataTextField: "text",
	        dataValueField: "value",
	        dataSource: _educationData,
	        index:<?=StaffData::getSelectIndex($value['educational'],StaffData::getEducation()); ?>
	    })
    <?php endforeach; ?>

    <?php foreach ($oData['certificate_ext'] as $key => $value):?>
    	$("#get_date_<?=$value['id'] ?>").kendoDatePicker({format:"MM/dd/yyyy"});
    <?php endforeach ?>

    <?php foreach ($oData['work_ext'] as $key => $value):?>
    	$("#start_date_<?=$value['id'] ?>").kendoDatePicker({format:"MM/dd/yyyy"});
    	$("#end_date_<?=$value['id'] ?>").kendoDatePicker({format:"MM/dd/yyyy"});
    <?php endforeach ?>

	$("#add-certificate").click(function(e){
		var _guid = guid();

		var _html = '<tr>\
			<th width="16%">\
			<input type="hidden" name="certificate_id[]" />\
				时间：\
			</th>\
			<td width="16%">\
				<input type="text" id='+_guid+' name="certificate_get_date_arr[]" style="width:120px;">\
			</td>\
			<th width="16%">\
				名称：\
			</th>\
			<td width="16%">\
				<input type="text" class="k-input k-textbox" name="certificate_name_arr[]" style="width:120px;">\
			</td>\
			<th width="16%">\
				成绩：\
			</th>\
			<td width="16%">\
				<input type="text" class="k-input k-textbox" name="certificate_result_arr[]" style="width:120px;">\
			</td>\
			<td width="1%">\
				<a href="javascript:;" class="del-row"><i class="glyphicon glyphicon-remove"></i></a>\
			</td>\
		</tr>';

		$("#certificate-table").append(_html);

		$("#"+_guid).kendoDatePicker({
    		format:"MM/dd/yyyy"
    	})

		$(".del-row").click(function(e){
			$(this).parents("tr").remove();
		})

	});

	var _idIndex = 0;
	$("#add-education").click(function(e){
		var _startId = guid();

		var _endId = guid();

		var _education = guid();

		var _html = '<div class="row m-table-row" style="margin-top:10px;">\
			&nbsp;&nbsp;\
			<input type="hidden" name="education_id[]" />\
			<div class="label">开始时间</div>\
			&nbsp;&nbsp;\
			<input type="text" id='+_startId+' name="education_start_date_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">结束时间</div>\
			&nbsp;&nbsp;\
			<input type="text" id='+_endId+' name="education_end_date_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">教育机构</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="education_organization_arr[]" style="width:121px;float:left;">\
			<br>\
			<br>\
			&nbsp;&nbsp;\
			<div class="label">专业</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="education_major_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">学历</div>\
			&nbsp;&nbsp;\
			<input type="text" id='+_education+' name="educational_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<a href="javascript:;" class="del-row"><i class="glyphicon glyphicon-remove"></i></a>\
		</div>';

		$("#education-box").append(_html);

		$("#"+_startId).kendoDatePicker({
    		format:"MM/dd/yyyy"
    	})

    	$("#"+_endId).kendoDatePicker({
    		format:"MM/dd/yyyy"
    	})

    	$("#"+_education).kendoDropDownList({
	        dataTextField: "text",
	        dataValueField: "value",
	        dataSource: JSON.parse('<?=json_encode(StaffData::getEducation()); ?>'),
	      	index:-1
	    })

		$(".del-row").click(function(e){
			$(this).parents(".m-table-row").remove();
		})
	});

	$("#add-member").click(function(e){
		var _html = '<div class="row m-table-row" style="margin-top:10px;">\
			&nbsp;&nbsp;\
			<input type="hidden" name="member_id[]" />\
			<div class="label">姓名</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="member_name_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">关系</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="member_relationship_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">工作单位</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="member_work_unit_arr[]" style="width:121px;float:left;">\
			<br>\
			<br>\
			&nbsp;&nbsp;\
			<div class="label">职业</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="member_position_name_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">电话</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="member_tel_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<a href="javascript:;" class="del-row"><i class="glyphicon glyphicon-remove"></i></a>\
		</div>';

		$("#member-box").append(_html);

		$(".del-row").click(function(e){
			$(this).parents(".m-table-row").remove();
		})
	})


	$("#add-word").click(function(e){

		var _startId = guid();

		var _endId = guid();

		var _html = '<div class="row m-table-row" style="margin-top:10px;">\
			&nbsp;&nbsp;\
			<input type="hidden" name="word_id[]" />\
			<div class="label">开始时间</div>\
			&nbsp;&nbsp;\
			<input type="text" id='+_startId+' name="word_start_date_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">结束时间</div>\
			&nbsp;&nbsp;\
			<input type="text" id='+_endId+' name="word_end_date_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">单位名称</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="word_unit_name_arr[]" style="width:121px;float:left;">\
			<br>\
			<br>\
			&nbsp;&nbsp;\
			<div class="label">职位</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="word_position_name_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<div class="label">离职原因</div>\
			&nbsp;&nbsp;\
			<input type="text" class="k-input k-textbox" name="word_leave_reason_arr[]" style="width:121px;float:left;">\
			&nbsp;&nbsp;\
			<a href="javascript:;" class="del-row"><i class="glyphicon glyphicon-remove"></i></a>\
		</div>';

		$("#word-box").append(_html);

		$("#"+_startId).kendoDatePicker({
    		format:"MM/dd/yyyy"
    	})

    	$("#"+_endId).kendoDatePicker({
    		format:"MM/dd/yyyy"
    	})

		$(".del-row").click(function(e){
			$(this).parents(".m-table-row").remove();
		})
	})
})


function setGroup(_unitId,_bIndex){
	$.ajax({
		url: "<?=Url::toRoute(['/hr/unit/default/getselectall']); ?>",
        dataType: "json",
        type:"GET",
        data:{unit_id:_unitId,type:2},
        success:function(redata){
        	var _groupIds = new Array;
        	for (var i = 0; i < redata.length ; i++) {
        		_groupIds[i]=redata[i].value;
        	}

			var _index= _groupIds.indexOf('<?=$oData["group_id"]; ?>');

        	if(_bIndex == false){
        		_index= -1;
        		$("#group_name").val("");
        	}
			
        	$("#group_id").kendoDropDownList({
		        dataTextField: "text",
		        dataValueField: "value",
		        dataSource: redata,
		        change:function(e){
		        	var _value = $("#group_id").data("kendoDropDownList").text();
		        	$("#group_name").val(_value);
		        } 
		    });
        	var dropdownlist = $("#group_id").data("kendoDropDownList");

        	dropdownlist.select(_index);

		    dropdownlist.refresh();
        }
	})
}

function setPosition(_unitId,_bIndex){
	$.ajax({
		url: "<?=Url::toRoute(['/hr/position/default/getselectallbyunitid']); ?>",
        dataType: "json",
        type:"GET",
        data:{unit_id:_unitId},
        success:function(redata){
        	var _positionIds = new Array;
        	for (var i = 0; i < redata.length ; i++) {
        		_positionIds[i]=redata[i].value;
        	}
			
			var _index= _positionIds.indexOf('<?=$oData["position_id"]; ?>');

        	if(_bIndex == false){
        		_index= -1;
        		$("#position_name").val("");
        	}
        
    		$("#position_id").kendoDropDownList({
		        dataTextField: "text",
		        dataValueField: "value",
		        dataSource: redata,
	
		        change:function(e){
		        	var _value = $("#position_id").data("kendoDropDownList").text();
		        	$("#position_name").val(_value);
		        } 
		    })
        	var dropdownlist = $("#position_id").data("kendoDropDownList");

        	dropdownlist.select(_index);

		    dropdownlist.refresh();
        }
	})
}

function guid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
        return v.toString(16);
    });
}



</script>